﻿using System;
using System.Net;
#if Phone
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
#endif

namespace SharedData
{
    /// <summary>
    /// Represents a single lunch item.
    /// </summary>
    [System.Runtime.Serialization.DataContract]
    public class Lunch
    {
        /// <summary>
        /// The date, in a string so that it can be parsed.
        /// </summary>
        [System.Runtime.Serialization.DataMember(Name = "date")]
        public string DateString
        {
            get
            {
                return this.Date.ToShortDateString();
            }
            set
            {
                string d = value.Substring(6, 2);
                string m = value.Substring(4, 2);
                string y = value.Substring(0, 4);

                if (value.Contains(@"/"))
                    this.Date = DateTime.Parse(value);
                else
                    this.Date = new DateTime(int.Parse(y), int.Parse(m), int.Parse(d));
            }
        }


        /// <summary>
        /// The date of the lunch
        /// </summary>
        [System.Runtime.Serialization.IgnoreDataMember]
        public DateTime Date { get; set; }

        /// <summary>
        /// The name of the lunch.
        /// </summary>
        [System.Runtime.Serialization.DataMember(Name = "name")]
        public string LunchName { get; set; }
    }
}
